package operation;

import Book.Book;
import Book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:26554
 * Date:2024-11-17
 * Time:13:13
 */
public class LookforOperation implements IOPeration{
    public void work(Booklist booklist){
        int ret = -1;
        System.out.println("查找图书");
        System.out.println("请输入要查找的书名");
        Scanner san = new Scanner(System.in);
        String lookforname = san.nextLine();
        int currentsize = booklist.getActualbooks();
        for (int i = 0; i < currentsize; i++) {
            String bookname = booklist.getbook(i).getName();
            if(lookforname.equals(bookname)){
                System.out.println("找到了");
                System.out.println(booklist.getbook(i));
                ret = 1;
            }
        }
        if(ret==-1){
            System.out.println("找不到此书");
        }
    }
}
